package tests;



import tester.*;

@Example
public class CycleTest {

	public CycleTest(){}
	
	
	static StopWatch sw = new StopWatch();
	@TestMethod
	public void cycleTest(Tester t){
		sw.start();
		for(int i = 0; i < 10000; i++){
			t.checkExpect(new StringBuilder("Foo").toString(), "Foo");
		}
		sw.stop();
	}
	
	public static void main(String[] args){
		Tester.runFullReport(new CycleTest());
		System.out.println("\n\n\nSpeed:\nMilli:  " + sw.getElapsedTime()
							+ "\nSec: " + sw.getElapsedTimeSecs());
	}
	
}

class StopWatch {
    
    private long startTime = 0;
    private long stopTime = 0;
    private boolean running = false;

    
    public void start() {
        this.startTime = System.currentTimeMillis();
        this.running = true;
    }

    
    public void stop() {
        this.stopTime = System.currentTimeMillis();
        this.running = false;
    }

    
    //elaspsed time in milliseconds
    public long getElapsedTime() {
        long elapsed;
        if (running) {
             elapsed = (System.currentTimeMillis() - startTime);
        }
        else {
            elapsed = (stopTime - startTime);
        }
        return elapsed;
    }
    
    
    //elaspsed time in seconds
    public long getElapsedTimeSecs() {
        long elapsed;
        if (running) {
            elapsed = ((System.currentTimeMillis() - startTime) / 1000);
        }
        else {
            elapsed = ((stopTime - startTime) / 1000);
        }
        return elapsed;
    }
}
